var isPalindrome = function(x) {
    if (x < 0){
        return false;
    }

    p = x;
    q = new Number(0);

    while (p >=10){
        q *= 10;
        q += p%10;
        p = parseInt(p/10);
    }
    
    return q == parseInt(x/10) && p == x%10;
};

console.log(isPalindrome(12321));